Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@skarab/detect-package-manager

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skarab/detect-package-manager

Detects which package manager (bun, pnpm, yarn, npm) is used based on the current working directory.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@skarab/detect-package-manager

Detects which package manager (bun, pnpm, yarn, npm) is used based on the current working directory.

Features

  • Support packageManager field in package.json.
  • Detect PM agent version from lock file name, format or version.
  • Fully typed and well tested!

TODO

  • Resolve external lock file such as lockfile-directory in .npmrc (PR welcome).

Installation

pnpm add @skarab/detect-package-manager

Usage

Detect the PM agent from the current working directory.

import { detectAgent } from '@skarab/detect-package-manager';

const agent = await detectAgent();

console.log(agent); // { name: 'pnpm', version: '7.6.0' }

Detect the PM agent from a provided directory.

import { detectAgent } from '@skarab/detect-package-manager';

const agent = await detectAgent('path/to/yarn/project');

console.log(agent); // { name: 'yarn', version: '1.22.17' }

Detect all installed and known agents.

import { detectInstalledAgents } from '@skarab/detect-package-manager';

const agents = await api.detectInstalledAgents();

console.log(agents.has('pnpm')); // true

// agents === Map(3) {
//   'pnpm' => { name: 'pnpm', version: '7.6.0' },
//   'yarn' => { name: 'yarn', version: '1.22.17' },
//   'npm' => { name: 'npm', version: '8.13.2' }
// }

Known agents

  • bun Bun is a fast all-in-one JavaScript runtime.
  • pnpm Fast, disk space efficient package manager.
  • yarn Yarn is a package manager that doubles down as project manager.
  • npm A JavaScript package manager.

Scaffolded with @skarab/skaffold

Keywords

FAQs

Package last updated on 05 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc